
	<div class='fixed hwrap'>
		<a href='javascript:history.back(-1);' target='_parent' class='rel'>
			<i class='icon-angle-left'></i>
		</a>
		<a href='javascript:;' target='_parent'></a>
		<h3 class='dyc'>修改密码</h3>
	</div>
	<div style='height:45px;'></div>
	<div class="aress_wrap">
  <ul class="wrap">
    <form name="UserPasForm" class="layui-form">
	<input name="newtel"  type="hidden" value="<?=$userinfo['phone'];?>">
    <li>
    	<span class="lab">原密码：</span>
        <input type="password" name="oldpassword" required lay-verify="required" placeholder="请输入原密码">
    </li>
    <li>
    	<span class="lab">新密码：</span>
        <input type="password" name="newpassword" required lay-verify="required" placeholder="请输入登录密码">
    </li>
	<li>
    	<span class="lab">确认密码</span>
        <input type="password" name="repassword" required lay-verify="required" placeholder="请输入登录密码">
    </li>
    <li class="notR">
    	<input type="text" required lay-verify="required" name="code" placeholder="请输入验证码">
		<button type="button" class="aress_btn" lay-ignore style="background:#f2f2f2" onclick="sendsms(this,60,'remake')">获取验证码</button>
    </li>
	<div class="mDivButton" lay-submit  lay-filter="myform">保存</div>
    </form>
  </ul>
</div>

<script type='text/javascript'>

//发送短信
function sendsms(e,second,type){
    var newtel = document.UserPasForm.newtel.value;
    var oldpassword = document.UserPasForm.oldpassword.value;
    if(!oldpassword){
        layer.msg('请填写原密码');
        return false;
    }
    var reg = /^1[0-9]{10}$/;
    if(!reg.test(newtel)){
        layer.msg('请填写正确的手机号');
        return false;
    }

      $.ajax({
          url:"<?=url('publics/sendSms');?>",
          method:"post",
          dataType:"json",
          data:{phone:newtel,type:type,oldpassword:oldpassword},
          success:function(rs){
              if(rs.code!=0){
                  layer.msg(rs.msg);
                  return false;
              }
              $(e).attr("disabled");
              $(e).text("重新发送(" + second + ")");
              var index = setInterval(function(rs) {
                  countdown = parseInt(/(\d+)/gi.exec($(e).text()));
                  if (countdown == 0) {
                      $(e).removeAttr("disabled");
                      $(e).text("获取验证码");
                      clearInterval(index);
                      return false;
                  } else {
                      $(e).attr("disabled", true);
                      countdown--;
                      $(e).text("重新发送(" + countdown + ")");
                  }
              },1000);
          }
      });
  }

</script>
